def input_password():
    pwd = input("请输入密码：")
    if len(pwd) >= 8:
        return pwd
    print(f"密码长度不够，请重新输入：{len(pwd)}")
    ex = Exception("密码长度不够")
    raise ex

try:
    pwd = input_password()
    print(pwd)
except Exception as e:
    print('发现错误: %s' % e)